package chouJiang;


import java.util.ArrayList;
import java.util.Collections;

public class MyThread extends Thread {
	ArrayList<Integer> list;
	Integer max = 0;
	Integer sum = 0;
	public MyThread(ArrayList<Integer> list) {
		this.list = list;
	}
/*	ArrayList<Integer> list1=new ArrayList<>();
	ArrayList<Integer> list2=new ArrayList<>();*/
	@Override
	public void run() {
		ArrayList<Integer> bokList=new ArrayList<>();
		while(true){
			synchronized (MyThread.class) {
				if(list.size()==0){
					System.out.println(getName()+bokList+"最大金额:"+max+";  一共"+sum);
					break;
				}else{
					//继续抽奖
					Collections.shuffle(list);
					Integer prize = list.remove(0);
					System.out.println(getName()+"又产生了一个:"+prize+"元大奖");
					if(prize>max) {
						max=prize;
					}
					sum+=prize;
					bokList.add(prize);
				}
				try {
					Thread.sleep(10);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
